package com.demo.controller;

import com.demo.service.StudentService2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * 使用Setter注解获取Bean
 */

@Controller
public class StudentController3 {
    // 使用Setter注解获取Bean
    private StudentService2 studentService2;

    // 不要忘记加注解
   // @Autowired
    @Resource
    public void setStudentService2(StudentService2 studentService2) {
        this.studentService2 = studentService2;
    }

    public void sayYe() {
        studentService2.sayYe();
    }
}
